﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using APNS.NET;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace APNSUnitTests.given_a_notification_response
{
   
    public class when_I_read_a_notification_response
    {

        [TestClass]
        public class from_a_valid_byte_array
        {

            [TestMethod]
            public void then_a_valid_response_should_be_read()
            {
                byte[] responseBytes = new byte[] { 8, 6, 2, 1, 0, 0 };
                var response = ApnsNotificationResponse.FromByteArray(responseBytes);
                Assert.AreEqual(258, response.NotificationId);
                Assert.AreEqual(NotificationStatusCode.InvalidTopicSize, response.StatusCode);
            }

        }

        [TestClass]
        public class from_an_invalid_byte_array
        {

            [TestMethod]
            public void then_a_response_should_not_be_read()
            {
                byte[] responseBytes = new byte[] { 2, 6, 2, 1, 0, 0 };
                var response = ApnsNotificationResponse.FromByteArray(responseBytes);
                Assert.IsNull(response);
            }

        }

        [TestClass]
        public class from_a_short_byte_array
        {

            [TestMethod]
            public void then_no_response_should_be_read()
            {
                byte[] responseBytes = new byte[] { 8, 6, 2, 1, 0 };
                var response = ApnsNotificationResponse.FromByteArray(responseBytes);
                Assert.IsNull(response);
            }

        }

        
    }
}
